<?php

/**
 * Created by PhpStorm.
 * User: steven
 * Date: 2016/3/25
 * Time: 19:31
 */
class Access_Token_Model extends CI_Model
{
    public function __construct()
    {
        $this->load->database();
    }

    public function get_access_token(){
        $query = $this->db->get('access_token');
        return $query->row_array();
    }

    public function get_sys_access_token(){
        $sql="select * from access_token where token_type='1'";
        $query=$this->db->query($sql);
        $arr=$query->result_array();
        return $arr;
    }

    public function get_web_access_token(){
        $sql="select * from access_token where  token_type='2'";
        $query=$this->db->query($sql);
        $arr=$query->result_array();
        return $arr;
    }

    public function update_access_token($data){
        $this->db->where('id',$data['id']);
        $this->db->update('access_token',$data);
        $affectioned=$this->db->affected_rows();
        if($affectioned>0){
            return true;
        }else{
            return false;
        }
    }

    public function insert_access_token($data){
        $this->db->insert('access_token',$data);
        $affectlines=$this->db->affected_rows();
        if($affectlines>0){
            return $this->db->insert_id();
        }else{
            return false;
        }

    }
}